﻿//Copyright 2011 - Jonathan Allen

using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics.Contracts;

namespace Granite
{
    /// <summary>
    /// Utiltiies for working with exceptions
    /// </summary>
    public static class ExceptionUtilities
    {
        /// <summary>
        /// This is used to create an ArgumentOutOfRangeException that includes the actual value. On some platforms an AnnotatedArgumentOutOfRangeException needs to be created instead of a ArgumentOutOfRangeException.
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="actualValue"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        [Pure]
        public static ArgumentOutOfRangeException ArgumentOutOfRangeException(string paramName, object actualValue, string message)
        {
            Contract.Ensures(Contract.Result<ArgumentOutOfRangeException>() != null);

#if !SILVERLIGHT && !XBOX360
            return new ArgumentOutOfRangeException(paramName, actualValue, message);
#else
            return new AnnotatedArgumentOutOfRangeException(paramName, actualValue, message);
#endif
        }
    }
    
}
